<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>组合继承</title>
</head>
<body>

</body>
<script>

    function SuperType() {// 父类
        this.name = "Lee";
        this.colors = ['white']

    }


    SuperType.prototype.sayHello=function () {
        alert("hello:"+this.name);
    }

    function SubType() { // 子类
        SuperType.call(this); // 借用构造器的方式
    }


    SubType.prototype = new SuperType();

    var sub1 = new  SubType();
    var sub2 = new  SubType();

    sub1.name = "Martin";
    sub1.sayHello();
    sub2.sayHello();


</script>
</html>